<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>Vue 测试实例 - 菜鸟教程(runoob.com)</title>
    <script src="https://cdn.staticfile.org/vue/2.4.2/vue.min.js"></script>
</head>

<body>
    <div id="demo">
        <input v-model="msg" />
        <br />
        {{msg}}
    </div>
    <input type="button" value="点击销毁" id="destroy" onclick="destroy()" />
    <script>
        var vm = new Vue({
            el: "#demo",
            data: {
                msg: "message",
            },
            //实例创建阶段
            created: function () {
                alert("created阶段");
            },
            //编译之前
            beforeCompile: function () {
                alert("beforeCompile阶段");
            },
            compiled: function () {
                alert("compiled阶段");
            },
            //准备阶段
            ready: function () {
                alert("ready阶段");
            },
            //销毁之前
            beforeDestroy: function () {
                alert("beforeDestroy阶段");
            },
            //销毁阶段
            destroyed: function () {
                alert("destroyed阶段");
            }
        });
        //点击按钮销毁事件，销毁之后绑定无效。
        function destroy() { vm.$destroy(); };
    </script>
</body>

</html>